package com.ruoyi.project.his.controller;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.his.domain.DoctorProjectFee;
import com.ruoyi.project.his.service.IDoctorProjectFeeService;
import com.sun.javadoc.Doc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Classname DoctorProjectFeeController
 * @Description
 * @Date 2022/6/27 19:16
 * @Author Lee
 */
@RestController
@RequestMapping("/his/profee")
public class DoctorProjectFeeController extends BaseController {
    @Autowired
    private IDoctorProjectFeeService projectFeeService;

    @PreAuthorize("@ss.hasPermi('his:profee:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorProjectFee projectFee) {
        startPage();
        return getDataTable(projectFeeService.selectDoctorProjectFeeList(projectFee));
    }


    @PreAuthorize("@ss.hasPermi('his:profee:query')")
    @GetMapping("/{projectId}")
    public AjaxResult getInfo(@PathVariable Integer projectId) {
        return AjaxResult.success(projectFeeService.selectDoctorProjectFeeById(projectId));
    }

    @PreAuthorize("@ss.hasPermi('his:profee:add')")
    @Log(title = "检查项目管理",businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult add(@Validated @RequestBody DoctorProjectFee projectFee) {
        projectFee.setCreateBy(SecurityUtils.getUsername());
        return toAjax(projectFeeService.insertDoctorProjectFee(projectFee));
    }

    @PreAuthorize("@ss.hasPermi('his:profee:edit')")
    @Log(title = "检查项目管理",businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult modify(@Validated @RequestBody DoctorProjectFee projectFee) {
        projectFee.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(projectFeeService.updateDoctorProjectFee(projectFee));
    }


    @PreAuthorize("@ss.hasPermi('his:profee:delete')")
    @Log(title = "检查项目管理",businessType = BusinessType.DELETE)
    @DeleteMapping("/{projectIds}")
    public AjaxResult batchRemove(@PathVariable Integer[] projectIds) {

        return toAjax(projectFeeService.batchDeleteByProjectIds(projectIds));
    }
}
